﻿using System;
using System.Collections;
using System.Collections.Generic;
using KKSG;
using UnityEngine;
using UnityEngine.SceneManagement;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x02000ED7 RID: 3799
	public sealed class XSceneLoader : MonoBehaviour
	{
		// Token: 0x0600C93B RID: 51515 RVA: 0x002D20C4 File Offset: 0x002D02C4
		public void LoadScene(string scene, EXStage eStage, bool prograss, uint nextsceneid, uint currentsceneid)
		{
			XSingleton<XGame>.singleton.notLoadScene = false;
			XSingleton<XGame>.singleton.networkRun = false;
			XSingleton<XTimerMgr>.singleton.update = false;
			this._loading_scene_id = nextsceneid;
			this._loading_scene_stage = eStage;
			this._prograss = prograss;
			XSingleton<XClientNetwork>.singleton.Clear();
			ObjectPoolCache.Clear();
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.ClearClass();
			bool settingEnum = XSingleton<XGlobalConfig>.singleton.GetSettingEnum(ESettingConfig.EClearBundle);
			if (settingEnum)
			{
				XSingleton<XUpdater.XUpdater>.singleton.Clear();
			}
			XSingleton<XDebug>.singleton.BeginRecord();
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.MarkLevelEnd();
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.MarkLoadlevel(scene);
			XQualitySetting.SwitchScene();
			XSingleton<XGameUI>.singleton.m_uiTool.PreLoad(false);
			XSingleton<XGameUI>.singleton.m_uiTool.ReleaseAllDrawCall();
			XSingleton<XResourceLoaderMgr>.singleton.CallUnloadCallback();
			XSingleton<XResourceLoaderMgr>.singleton.ReleasePool();
			this._DelayLoadCache = XSingleton<XResourceLoaderMgr>.singleton.DelayLoad;
			XSingleton<XResourceLoaderMgr>.singleton.DelayLoad = false;
			//zcg XSpectateDocument specificDocument = XDocuments.GetSpecificDocument<XSpectateDocument>(XSpectateDocument.uuID);
			//zcg this._LoadingSpectateScene = specificDocument.IsLoadingSpectateScene;
			SceneType sceneType = XSingleton<XSceneMgr>.singleton.GetSceneType(nextsceneid);
			//bool flag = SceneType.SCENE_PK != sceneType && SceneType.SCENE_INVFIGHT != sceneType && SceneType.SCENE_LEAGUE_BATTLE != sceneType;
			if (SceneType.SCENE_PK != sceneType && SceneType.SCENE_INVFIGHT != sceneType && SceneType.SCENE_LEAGUE_BATTLE != sceneType)
			{
				DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.Load();
				//zcg 
// 				bool isLoadingSpectateScene = specificDocument.IsLoadingSpectateScene;
// 				if (isLoadingSpectateScene)
// 				{
// 					specificDocument.IsLoadingSpectateScene = false;
// 					string[] array = XSingleton<XGlobalConfig>.singleton.GetValue("Spectate_Tips").Split(XGlobalConfig.ListSeparator);
// 					int num = UnityEngine.Random.Range(0, array.Length);
// 					DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetLoadingTip(array[num]);
// 				}
// 				else
				{
					string loadingTip = (currentsceneid == 1U) ? XSingleton<XSceneMgr>.singleton.GetSceneLoadingTips(true, nextsceneid) : ((nextsceneid == 1U) ? XSingleton<XSceneMgr>.singleton.GetSceneLoadingTips(false, currentsceneid) : ((nextsceneid == 100U) ? XSingleton<XSceneMgr>.singleton.GetSceneLoadingTips(true, nextsceneid) : ((nextsceneid == 3U) ? XSingleton<XSceneMgr>.singleton.GetSceneLoadingTips(false, 2U) : XSingleton<XSceneMgr>.singleton.GetSceneLoadingTips(true, nextsceneid))));
					DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetLoadingTip(loadingTip);
				}
				//bool flag2 = nextsceneid == 100U || nextsceneid == 21U || nextsceneid == 22U;
				string text;
				if (nextsceneid == 100U || nextsceneid == 21U || nextsceneid == 22U)
				{
					text = this.GetMyProfessionLoadingPic();
				}
				else
				{
					text = XSingleton<XSceneMgr>.singleton.GetSceneLoadingPic(nextsceneid);
				}
				//bool flag3 = string.IsNullOrEmpty(text);
				if (string.IsNullOrEmpty(text))
				{
					prograss = false;
				}
				else
				{
					DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetLoadingPic(text);
				}
				DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetVisible(prograss, true);
				DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetLoadingProgress(0f);
			}
			Application.backgroundLoadingPriority = ThreadPriority.High;
			base.StartCoroutine(this.LoadLevelWithProgress(scene));
			XSingleton<XScene>.singleton.OnSceneBeginLoad(this._loading_scene_id);
		}

		// Token: 0x0600C93C RID: 51516 RVA: 0x002D237E File Offset: 0x002D057E
		private IEnumerator LoadLevelWithProgress(string scene)
		{
			base.enabled = true;
			this._enabled = true;
			this._current_progress = 0f;
			this._target_progress = 0f;
			this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Downlaod, 1f);
			yield return null;
			SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
			//bool flag = SceneType.SCENE_PK == sceneType || SceneType.SCENE_INVFIGHT == sceneType;
			if (SceneType.SCENE_PK == sceneType || SceneType.SCENE_INVFIGHT == sceneType)
			{
				//zcg DlgBase<XPkLoadingView, XPkLoadingBehaviour>.singleton.ShowPkLoading(sceneType);
			}
			else
			{
				//bool flag2 = SceneType.SCENE_LEAGUE_BATTLE == sceneType;
				if (SceneType.SCENE_LEAGUE_BATTLE == sceneType)
				{
					//zcg DlgBase<XTeamLeagueLoadingView, XTeamLeagueLoadingBehaviour>.singleton.ShowPkLoading();
				}
				else
				{
					//bool flag3 = SceneType.SCENE_PKTWO == sceneType;
					if (SceneType.SCENE_PKTWO == sceneType)
					{
						//zcg DlgBase<XMultiPkLoadingView, XMultiPkLoadingBehaviour>.singleton.ShowPkLoading();
					}
				}
			}
			XSingleton<XGameUI>.singleton.m_uiTool.EnableUILoadingUpdate(true);
			yield return null;
			this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Load, 0f);
			//bool flag4 = XSingleton<XUpdater.XUpdater>.singleton.ABManager != null;
			if (XSingleton<XUpdater.XUpdater>.singleton.ABManager != null)
			{
				XSingleton<XUpdater.XUpdater>.singleton.ABManager.UnloadUnusedBundle(true);
			}
			this._op = SceneManager.LoadSceneAsync("empty");
			while (!this._op.isDone)
			{
				yield return null;
			}
			this._op = Resources.UnloadUnusedAssets();
			while (!this._op.isDone)
			{
				yield return null;
			}
			XSingleton<XResourceLoaderMgr>.singleton.LoadABScene(XSingleton<XSceneMgr>.singleton.GetScenePath(this._loading_scene_id));
			this._op = SceneManager.LoadSceneAsync(scene);
			while (!this._op.isDone)
			{
				yield return null;
			}
			XSingleton<XResourceLoaderMgr>.singleton.DelayLoad = this._DelayLoadCache;
			XQualitySetting.PostSceneLoad();
			this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Load, 1f);
			XSingleton<XDebug>.singleton.AddLog("-------------scene ready & begin load other res-------------", null, null, null, null, null, XDebugColor.XDebug_None);
			yield return null;
			this._asbr = this.SceneBuildAsync(this._loading_scene_id);
			yield return null;
			while (this._asbr.Pedometer.MoveNext())
			{
				this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Build, this._asbr.Progress);
				yield return null;
			}
			this._asbr = null;
			bool prograss = this._prograss;
			if (prograss)
			{
				//bool flag5 = XStage.IsConcreteStage(this._loading_scene_stage);
				if (XStage.IsConcreteStage(this._loading_scene_stage))
				{
					XSingleton<XScene>.singleton.RefreshScenMustTransform();
					this.CreatePlayer();
					this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Doc, 0.3f);
					yield return null;
					IEnumerator iter = this.DocPreload(this._loading_scene_id);
					while (iter.MoveNext())
					{
						this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Doc, 0.3f + 0.4f * this._sub_progress);
						yield return null;
					}
					iter = null;
				}
				XSingleton<XGame>.singleton.OnEnterScene(this._loading_scene_id, false);
				this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Doc, 0.9f);
				//bool flag6 = this._loading_scene_id == 100U;
				if (this._loading_scene_id == 100U)
				{
					uint idx = XSingleton<XEntityMgr>.singleton.Player.BasicTypeID - 1U;
					uint id = XSingleton<XGlobalConfig>.singleton.NewbieLevelRoleID[(int)idx];
					XEntityStatistics.RowData raw = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(id);
					XSingleton<XEntityMgr>.singleton.Player.OnTransform(raw.ID);
					yield return null;
					raw = null;
				}
				this.DisplayPrograss(XSceneLoader.LoadingPhase.Scene_Doc, 1f);
				yield return null;
				this._target_progress = 0.9f;
				//bool flag7 = this._prograss && this._current_progress < 0.89f;
				if (this._prograss && this._current_progress < 0.89f)
				{
					yield return null;
				}
				this._enabled = false;
				DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetLoadingProgress(1f);
				yield return null;
				//bool flag8 = XStage.IsConcreteStage(this._loading_scene_stage);
				if (XStage.IsConcreteStage(this._loading_scene_stage))
				{
					RpcC2G_DoEnterScene DoEnterSceneRpc = new RpcC2G_DoEnterScene();
					DoEnterSceneRpc.oArg.sceneid = XSingleton<XScene>.singleton.SceneID;
					//XSingleton<XClientNetwork>.singleton.Send(DoEnterSceneRpc);
					XSingleton<XScene>.singleton.bSceneLoadedRpcSend = true;
					if (XDebug.isLocalTest)
                    {
                        XSingleton<XLoginDocument>.singleton.DoEnterScene(DoEnterSceneRpc);

                    }
                    else
                    {
                        XSingleton<XClientNetwork>.singleton.Send(DoEnterSceneRpc);
                    }
                    
					DoEnterSceneRpc = null;
				}
			}
			else
			{
				XSingleton<XGame>.singleton.OnEnterScene(this._loading_scene_id, false);
			}
			//bool flag9 = XStage.IsConcreteStage(this._loading_scene_stage);
			if (XStage.IsConcreteStage(this._loading_scene_stage))
			{
				yield return null;
			}
			else
			{
				XSingleton<XScene>.singleton.bSceneServerReady = (XSingleton<XScene>.singleton.Error == ErrorCode.ERR_SUCCESS);
				yield return null;
			}
			int waitTime = 1;
			XSingleton<XGame>.singleton.networkRun = true;
			while (!XSingleton<XScene>.singleton.bSceneServerReady)
			{
				int num = waitTime;
				waitTime = num + 1;
				//bool flag10 = XSingleton<XScene>.singleton.Error > ErrorCode.ERR_SUCCESS;
				if (XSingleton<XScene>.singleton.Error > ErrorCode.ERR_SUCCESS)
				{
					//bool flag11 = string.IsNullOrEmpty(XSingleton<XScene>.singleton.ErrorAddtional);
					if (string.IsNullOrEmpty(XSingleton<XScene>.singleton.ErrorAddtional))
					{
						XSingleton<UiUtility>.singleton.OnFatalErrorClosed(XSingleton<XScene>.singleton.Error);
					}
					else
					{
						XSingleton<UiUtility>.singleton.OnFatalErrorClosed(string.Format(XStringDefineProxy.GetString(XSingleton<XScene>.singleton.Error), XSingleton<XScene>.singleton.ErrorAddtional));
					}
					XSingleton<XScene>.singleton.Error = ErrorCode.ERR_SUCCESS;
					XSingleton<XScene>.singleton.ErrorAddtional = null;
					XSingleton<XClientNetwork>.singleton.CloseOnServerErrorNtf = false;
					break;
				}
				//bool flag12 = XSingleton<XScene>.singleton.SceneEntranceConfig != null;
				if (XSingleton<XScene>.singleton.SceneEntranceConfig != null)
				{
					this._prograss = false;
					XSingleton<XScene>.singleton.TriggerScene();
					break;
				}
				yield return null;
			}
			bool bSceneServerReady = XSingleton<XScene>.singleton.bSceneServerReady;
			if (bSceneServerReady)
			{
				this.PlayBGM(this._loading_scene_id);
				XAutoFade.MakeBlack(true);
				this._prograss = false;
				yield return null;
				DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.HideSelf(false);
				XSingleton<XScene>.singleton.TriggerScene();
				yield return null;
				XAutoFade.FadeIn(1f, true);
			}
			this._op = null;
			//bool flag13 = XSingleton<XScene>.singleton.SceneEntranceConfig != null;
			if (XSingleton<XScene>.singleton.SceneEntranceConfig != null)
			{
				XSingleton<XScene>.singleton.SceneEnterTo(true);
			}
			XSingleton<XGame>.singleton.notLoadScene = true;
			XSingleton<XGame>.singleton.switchScene = false;
			XSingleton<XTimerMgr>.singleton.update = true;
			Application.backgroundLoadingPriority = ThreadPriority.Normal;
			bool settingEnum = XSingleton<XGlobalConfig>.singleton.GetSettingEnum(ESettingConfig.ESceneUnloadResource);
			if (settingEnum)
			{
				Resources.UnloadUnusedAssets();
			}
			//bool flag14 = this._loading_scene_id == 1U;
			if (this._loading_scene_id == 1U)
			{
				GC.Collect();
			}
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.MarkLoadlevelCompleted();
			yield break;
		}

		// Token: 0x0600C93D RID: 51517 RVA: 0x002D2394 File Offset: 0x002D0594
		private void Update()
		{
			//bool flag = this._enabled && this._prograss;
			if (this._enabled && this._prograss)
			{
				this._current_progress += Mathf.Abs(this._target_progress - this._current_progress) * 0.5f;
				DlgBase<LoadingDlg, LoadingDlgBehaviour>.singleton.SetLoadingProgress(this._current_progress);
			}
		}

		// Token: 0x0600C93E RID: 51518 RVA: 0x002D23F0 File Offset: 0x002D05F0
		private void DisplayPrograss(XSceneLoader.LoadingPhase phase, float progress)
		{
			//bool flag = !this._prograss;
			if (this._prograss)
			{
				switch (phase)
				{
				case XSceneLoader.LoadingPhase.Scene_Downlaod:
					this._target_progress = progress * 0.1f;
					break;
				case XSceneLoader.LoadingPhase.Scene_Load:
					this._target_progress = progress * 0.2f + 0.1f;
					break;
				case XSceneLoader.LoadingPhase.Scene_Build:
					this._target_progress = progress * 0.4f + 0.3f;
					break;
				case XSceneLoader.LoadingPhase.Scene_Doc:
					this._target_progress = progress * 0.2f + 0.7f;
					break;
				}
			}
		}

		// Token: 0x0600C93F RID: 51519 RVA: 0x002D2480 File Offset: 0x002D0680
		private XSceneLoader.AsyncSceneBuildRequest SceneBuildAsync(uint sceneID)
		{
			return new XSceneLoader.AsyncSceneBuildRequest
			{
				Pedometer = this.Preloader(sceneID)
			};
		}

		// Token: 0x0600C940 RID: 51520 RVA: 0x002D24A6 File Offset: 0x002D06A6
		private IEnumerator Preloader(uint sceneID)
		{
			IEnumerator ietr = null;
			this._asbr.Progress = 0f;
			yield return null;
			XSingleton<XScene>.singleton.OnSceneLoaded(sceneID);
			this._asbr.Progress = 0.05f;
			yield return null;
			ietr = this.PreLoadSceneMonster(sceneID);
			while (ietr.MoveNext())
			{
				this._asbr.Progress = 0.05f + this._sub_progress * 0.75f;
				yield return null;
			}
			ietr = this.PreLoadSceneRes(sceneID);
			while (ietr.MoveNext())
			{
				this._asbr.Progress = 0.8f + this._sub_progress * 0.1f;
				yield return null;
			}
			ietr = this.PlaceSceneNpc(sceneID);
			while (ietr.MoveNext())
			{
				this._asbr.Progress = 0.9f + this._sub_progress * 0.1f;
				yield return null;
			}
			this._asbr.Progress = 1f;
			yield break;
		}

		// Token: 0x0600C941 RID: 51521 RVA: 0x002D24BC File Offset: 0x002D06BC
		private void CreatePlayer()
		{
			this._sub_progress = 0f;
			XSingleton<XDebug>.singleton.AddLog("Preload Player", null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XEntityMgr>.singleton.Add(XSingleton<XEntityMgr>.singleton.CreatePlayer(Vector3.zero, Quaternion.identity, false, XSingleton<XScene>.singleton.IsMustTransform || this._LoadingSpectateScene));
			this._LoadingSpectateScene = false;
		}

		// Token: 0x0600C942 RID: 51522 RVA: 0x002D2527 File Offset: 0x002D0727
		private IEnumerator PlaceSceneNpc(uint sceneID)
		{
			this._sub_progress = 0f;
			List<uint> npcList = XSingleton<XEntityMgr>.singleton.GetNpcs(sceneID);
			//bool flag = npcList != null && npcList.Count > 0;
			if (npcList != null && npcList.Count > 0)
			{
				int step = 0;
				XTaskDocument taskDoc = XDocuments.GetSpecificDocument<XTaskDocument>(XTaskDocument.uuID);
				int num;
				for (int i = 0; i < npcList.Count; i = num + 1)
				{
					num = step;
					step = num + 1;
					//bool flag2 = !taskDoc.ShouldNpcExist(npcList[i]);
					if (/*!flag2*/taskDoc.ShouldNpcExist(npcList[i]))
					{
						XSingleton<XEntityMgr>.singleton.CreateNpc(npcList[i], true);
						this._sub_progress = (float)step / (float)npcList.Count;
					}
					num = i;
				}
				taskDoc = null;
			}
			this._sub_progress = 1f;
			yield return null;
			yield break;
		}

		// Token: 0x0600C943 RID: 51523 RVA: 0x002D253D File Offset: 0x002D073D
		private IEnumerator PreLoadSceneMonster(uint sceneID)
		{
			this._sub_progress = 0f;
			List<uint> prefabs = new List<uint>();
			XLevelSpawnMgr levelSpawnMgr = XSingleton<XLevelSpawnMgr>.singleton;
			XLevelSpawnInfo spawner = levelSpawnMgr.GetSpawnerBySceneID(sceneID);
			//bool flag = spawner != null;
			if (spawner != null)
			{
				Dictionary<int, int> preloadInfo = new Dictionary<int, int>();
				foreach (KeyValuePair<int, int> keyValuePair in spawner._preloadInfo)
				{
					//bool flag2 = keyValuePair.Key == 0;
					if (keyValuePair.Key != 0)
					{
						preloadInfo.Add(keyValuePair.Key, keyValuePair.Value);
						//todo
						//keyValuePair = default(KeyValuePair<int, int>);
					}
				}
				//Dictionary<int, int>.Enumerator enumerator = default(Dictionary<int, int>.Enumerator);
				//bool flag3 = !XSingleton<XLevelSpawnMgr>.singleton.ForcePreloadOneWave;
				if (!levelSpawnMgr.ForcePreloadOneWave)
				{
					int i = 0;
					while (i < levelSpawnMgr.MonsterIDs.Count && preloadInfo.Count < levelSpawnMgr.MaxPreloadCount)
					{
						//bool flag4 = XSingleton<XLevelSpawnMgr>.singleton.MonsterIDs[i] == 0U;
						if (/*!flag4*/levelSpawnMgr.MonsterIDs[i] != 0U)
						{
							//bool flag5 = !preloadInfo.ContainsKey((int)XSingleton<XLevelSpawnMgr>.singleton.MonsterIDs[i]);
							if (!preloadInfo.ContainsKey((int)levelSpawnMgr.MonsterIDs[i]))
							{
								preloadInfo.Add((int)levelSpawnMgr.MonsterIDs[i], 1);
							}
						}
						int num = i + 1;
						i = num;
					}
				}
				int step = 0;
				float progress = 0f;
				foreach (KeyValuePair<int, int> keyValuePair2 in preloadInfo)
				{
					int num = step++;
					progress = (float)step / (float)preloadInfo.Count * 0.9f;
					uint enemyID = (uint)keyValuePair2.Key;
					XEntityStatistics.RowData data = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(enemyID);
					if (data == null)
					{
						XSingleton<XDebug>.singleton.AddErrorLog("Cant find statistic id: ", enemyID.ToString(), null, null, null, null);
					}
					else
					{
						XEntityPresentation.RowData presentData = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(data.PresentID);
						if (presentData == null)
						{
							XSingleton<XDebug>.singleton.AddErrorLog("Cant find present id ", data.PresentID.ToString(), " while statistic id = ", data.ID.ToString(), null, null);
						}
						else
						{
							string prefab = presentData.Prefab;
							//bool flag8 = !prefabs.Contains(data.PresentID);
							if (!prefabs.Contains(data.PresentID))
							{
								string location = "Prefabs/" + prefab;
								float diff = progress - this._sub_progress;
								XSingleton<XResourceLoaderMgr>.singleton.CreateInAdvance(location, 1, ECreateHideType.DisableAnim);
								this._sub_progress += diff * 0.2f;
								XSingleton<XDebug>.singleton.AddLog("Preload ", prefab, " with pid ", data.PresentID.ToString(), null, null, XDebugColor.XDebug_None);
								XSingleton<XEntityMgr>.singleton.PreloadTemp(data.PresentID, enemyID, (EntitySpecies)data.Type);
								this._sub_progress += diff * 0.7f;
								prefabs.Add(data.PresentID);
								location = null;
							}
							this._sub_progress = progress;
							if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
							{
								yield return null;
							}
							data = null;
							presentData = null;
							prefab = null;
						}
					}
				}
				//Dictionary<int, int>.Enumerator enumerator2 = default(Dictionary<int, int>.Enumerator);
				this._sub_progress = 0.9f;
				XSingleton<XResourceLoaderMgr>.singleton.CreateInAdvance(XCombatHUDMgr.HUD_NORMAL, 10, ECreateHideType.NotHide);
				XSingleton<XResourceLoaderMgr>.singleton.CreateInAdvance(XCombatHUDMgr.HUD_CRITICAL, 5, ECreateHideType.NotHide);
				XSingleton<XResourceLoaderMgr>.singleton.CreateInAdvance(XCombatHUDMgr.HUD_PLAYER, 5, ECreateHideType.NotHide);
				this._sub_progress = 1f;
				preloadInfo = null;
			}
			//bool flag10 = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL;
			if (XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL)
			{
				//zcg XBillBoardDocument.PreLoad(16);
				XSingleton<XGameUI>.singleton.m_uiTool.PreLoad(true);
			}
			else if (XSingleton<XScene>.singleton.SceneType != SceneType.SCENE_LOGIN)
			{
				XSingleton<XGameUI>.singleton.m_uiTool.PreLoad(true);
			}
			yield return null;
			this._sub_progress = 1f;
			yield break;
			//yield break;
		}

		// Token: 0x0600C944 RID: 51524 RVA: 0x002D2553 File Offset: 0x002D0753
		private IEnumerator PreLoadSceneRes(uint sceneID)
		{
			this._sub_progress = 0f;
			//bool flag = sceneID > 3U;
			if (sceneID > 3U)
			{
				PreloadAnimationList.RowData[] Anims = XSingleton<XSceneMgr>.singleton.AnimReader.Table;
				int step = 0;
				int i = 0;
				int imax = Anims.Length;
				while (i < imax)
				{
					this._sub_progress = 0.5f + (float)step / ((float)Anims.Length * 2f);
					PreloadAnimationList.RowData rowData = Anims[i];
					//bool flag2 = rowData.SceneID == 0 || (long)rowData.SceneID == (long)((ulong)sceneID);
					int num;
					if (rowData.SceneID == 0 || (long)rowData.SceneID == (long)((ulong)sceneID))
					{
						num = step;
						step = num + 1;
						XSingleton<XResourceLoaderMgr>.singleton.GetXAnimation(rowData.AnimName, true, true);
						yield return null;
					}
					rowData = null;
					num = i + 1;
					i = num;
				}
				Anims = null;
			}
			this._sub_progress = 1f;
			yield break;
		}

		// Token: 0x0600C945 RID: 51525 RVA: 0x002D256C File Offset: 0x002D076C
		private void PlayBGM(uint sceneid)
		{
			string sceneBGM = XSingleton<XSceneMgr>.singleton.GetSceneBGM(sceneid);
			XSingleton<XAudioMgr>.singleton.PlayBGM(sceneBGM);
		}

		// Token: 0x0600C946 RID: 51526 RVA: 0x002D2592 File Offset: 0x002D0792
		private IEnumerator DocPreload(uint sceneid)
		{
			this._sub_progress = 0f;
			int num;
			for (int i = 0; i < XSingleton<XGame>.singleton.Doc.Components.Count; i = num + 1)
			{
				XSingleton<XGame>.singleton.Doc.Components[i].OnEnterScene();
				this._sub_progress = (float)i / (float)XSingleton<XGame>.singleton.Doc.Components.Count;
				num = i;
			}
			yield return null;
			this._sub_progress = 1f;
			yield break;
		}

		// Token: 0x0600C947 RID: 51527 RVA: 0x002D25A8 File Offset: 0x002D07A8
		private string GetMyProfessionLoadingPic()
		{
			uint num = XSingleton<XAttributeMgr>.singleton.XPlayerData.TypeID % 10U;
			string[] array = XSingleton<XGlobalConfig>.singleton.GetValue("ProfessionLoadingPic").Split(XGlobalConfig.AllSeparators);
			//bool flag = array.Length % 2 != 0;
			string result;
			if (array.Length % 2 != 0)
			{
				result = "";
			}
			else
			{
				for (int i = 0; i < array.Length; i += 2)
				{
					//bool flag2 = uint.Parse(array[i]) == num;
					if (uint.Parse(array[i]) == num)
					{
						return array[i + 1];
					}
				}
				result = "";
			}
			return result;
		}

		// Token: 0x040058F0 RID: 22768
		private AsyncOperation _op = null;

		// Token: 0x040058F1 RID: 22769
		private XSceneLoader.AsyncSceneBuildRequest _asbr = null;

		// Token: 0x040058F2 RID: 22770
		private uint _loading_scene_id = 0U;

		// Token: 0x040058F3 RID: 22771
		private EXStage _loading_scene_stage = EXStage.Null;

		// Token: 0x040058F4 RID: 22772
		private bool _enabled = false;

		// Token: 0x040058F5 RID: 22773
		private bool _prograss = true;

		// Token: 0x040058F6 RID: 22774
		private float _sub_progress = 0f;

		// Token: 0x040058F7 RID: 22775
		private float _current_progress = 0f;

		// Token: 0x040058F8 RID: 22776
		private float _target_progress = 0f;

		// Token: 0x040058F9 RID: 22777
		private bool _DelayLoadCache = true;

		// Token: 0x040058FA RID: 22778
		private bool _LoadingSpectateScene = false;

		// Token: 0x020019D9 RID: 6617
		private enum LoadingPhase
		{
			// Token: 0x04008027 RID: 32807
			Scene_Downlaod,
			// Token: 0x04008028 RID: 32808
			Scene_Load,
			// Token: 0x04008029 RID: 32809
			Scene_Build,
			// Token: 0x0400802A RID: 32810
			Scene_Doc
		}

		// Token: 0x020019DA RID: 6618
		private class AsyncSceneBuildRequest
		{
			// Token: 0x0400802B RID: 32811
			public float Progress = 1f;

			// Token: 0x0400802C RID: 32812
			public IEnumerator Pedometer = null;
		}
	}
}
